<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 220px;
            height: 220px;
            background-color: pink;
            border: 2px solid #ccc;
            padding: 10px;
        }
    </style>
</head>

<body>
    <div>

    </div>
    <script>

        var div = document.querySelector('div')
     
        //  client系列属性与offset获取值时特性基本一致 唯一不同的就是client获取值不包括边框
        console.log(div.clientWidth);//220
        console.log(div.clientHeight);//220

        // client系列属性有专门获取边框的属性 分别是clientLeft/Top;取过来的值同样是数字型不加px单位
        console.log(div.clientLeft);//2
        console.log(div.clientTop);//2
    </script>
</body>

</html>